package oj;

import lombok.Data;

/**
 * @author chaolong.jin
 * @description
 * @date 2019/08/24 12:30
 */
public class NodeListTest {
    @Data
    static class Node {
        private volatile int value;
        private Node next;

        public Node(int value, Node next) {
            this.value = value;
            this.next = next;
        }
    }

    public static void main(String[] args) {
        Node head = null;
        Node list = null;
        for (int i = 0; i < 10; i++) {
            Node node = new Node(i, null);
            if (list == null) {
                list = node;
                head = node;
            } else {
                list.next = node;
                list = list.next;
            }
        }
        Node convertHead = null;
        while (head != null) {
            Node node = new Node(head.value, null);
            node.next = convertHead;
            convertHead = node;
            System.out.print(head.value + " ");
            head = head.next;
        }
        System.out.println("");
        while (convertHead != null) {
            System.out.print(convertHead.value + " ");
            convertHead = convertHead.next;
        }
    }
}
